﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace cloud_sharing
{
    public partial class Form2 : Form
    {


        private FolderBrowserDialog folderBrowserDialog;
        private OpenFileDialog openFileDialog;
        public Form2()
        {
            InitializeComponent();
        }


        private void tabPage1_Click(object sender, EventArgs e)
        {

        }

        private void tabPage3_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void btnAccountMove_Click(object sender, EventArgs e)
        {
            String newLocation = "";
            folderBrowserDialog = new FolderBrowserDialog();
            DialogResult dialogResult = folderBrowserDialog.ShowDialog();
            if (dialogResult == DialogResult.OK)
            {
                newLocation = folderBrowserDialog.SelectedPath;
                tbAccountLocation.Text = newLocation;
            }

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter_1(object sender, EventArgs e)
        {

        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (radioBandwidthUploadLimit.Checked)
            {
                tbBandwitdthUploadRate.Enabled = true;
            }
        }

        private void radioBandwidthDownloadNoLimit_CheckedChanged(object sender, EventArgs e)
        {
            if (radioBandwidthDownloadNoLimit.Checked)
            {
                tbBandwidthDowloadRate.Enabled = false;
            }
        }

        private void radioBandwidthDownloadLimit_CheckedChanged(object sender, EventArgs e)
        {
            if (radioBandwidthDownloadLimit.Checked)
            {
                tbBandwidthDowloadRate.Enabled = true;
            }
        }

        private void radioBandwidthUploadNoLimit_CheckedChanged(object sender, EventArgs e)
        {
            if (radioBandwidthUploadNoLimit.Checked)
            {
                tbBandwitdthUploadRate.Enabled = false;
            }
        }

        private void radioBandwidthUploadLimitAuto_CheckedChanged(object sender, EventArgs e)
        {
            if (radioBandwidthUploadLimitAuto.Checked)
            {
                tbBandwitdthUploadRate.Enabled = false;
            }
        }

        private void radioProxyNo_CheckedChanged(object sender, EventArgs e)
        {
            if (radioProxyNo.Checked)
            {
                disableProxyControls();
            }
        }

        private void radioProxyAuto_CheckedChanged(object sender, EventArgs e)
        {
            if (radioProxyAuto.Checked)
            {
                disableProxyControls();
            }
        }

        private void radioProxyManual_CheckedChanged(object sender, EventArgs e)
        {
            if (radioProxyManual.Checked)
            {
                lbProxyType.Enabled = true;
                listProxyType.Enabled = true;
                lbProxyServer.Enabled = true;
                tbProxyHost.Enabled = true;
                lbProxyPort.Enabled = true;
                tbProxyPort.Enabled = true;
                cbProxyRequirePassword.Enabled = true;
            }
        }

        private void cbProxyRequirePassword_CheckedChanged(object sender, EventArgs e)
        {
            if (cbProxyRequirePassword.Checked)
            {
                lbProxyUserName.Enabled = true;
                tbProxyUsername.Enabled = true;
                lbProxyPassword.Enabled = true;
                tbProxyPassword.Enabled = true;
            }
            else
            {
                tbProxyUsername.Text = "";
                tbProxyPassword.Text = "";
                lbProxyUserName.Enabled = false;
                tbProxyUsername.Enabled = false;
                lbProxyPassword.Enabled = false;
                tbProxyPassword.Enabled = false;
            }
        }

        private void disableProxyControls()
        {
            lbProxyType.Enabled = false;
            listProxyType.Enabled = false;
            lbProxyServer.Enabled = false;
            tbProxyHost.Enabled = false;
            lbProxyPort.Enabled = false;
            tbProxyPort.Enabled = false;
            cbProxyRequirePassword.Checked = false;
            cbProxyRequirePassword.Enabled = false;
            lbProxyUserName.Enabled = false;
            tbProxyUsername.Enabled = false;
            lbProxyPassword.Enabled = false;
            tbProxyPassword.Enabled = false;
        }

        private void btnAccountSync_Click(object sender, EventArgs e)
        {
            String selectedFiles = "";
            openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = @"C:\temp\";
            openFileDialog.Multiselect = true;
            DialogResult dialogResult = openFileDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                if (openFileDialog.FileNames.Length > 0)
                {
                    foreach (String fileName in openFileDialog.FileNames)
                    {
                        selectedFiles += fileName;
                    }
                    tbAccountLocation.Text = selectedFiles;
                }
            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
